﻿using HotelManager.Common;
using HotelManager.Models;
using Prism.Ioc;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HotelManager.ViewModels
{
    public class PersonCenterViewModel: NavigationViewModel
    {
        private readonly IRegionManager regionManager;
        public PersonCenterViewModel(IContainerProvider provider): base(provider)
        {
            regionManager = provider.Resolve<IRegionManager>();
            UserName = AppSession.UserName;
            LoginId = AppSession.LoginId;
            Phone = AppSession.Phone;
            Photo = "http://localhost:8090/upload/"+AppSession.Photo;
            RoleName = AppSession.RoleId == 1 ? "系统管理员" : (AppSession.RoleId == 1?"普通管理员":"VIP用户");
        }
        private string userName;
        public string UserName
        {
            get { return userName; }
            set
            {
                userName = value;
                RaisePropertyChanged();
            }
        }
        private string loginId;
        public string LoginId
        {
            get { return loginId; }
            set
            {
                loginId = value;
                RaisePropertyChanged();
            }
        }
        private string phone;
        public string Phone
        {
            get { return phone; }
            set
            {
                phone = value;
                RaisePropertyChanged();
            }
        }
        private string photo;
        public string Photo
        {
            get { return photo; }
            set
            {
                photo = value;
                RaisePropertyChanged();
            }
        }
        private string roleName;
        public string RoleName
        {
            get { return roleName; }
            set
            {
                roleName = value;
                RaisePropertyChanged();
            }
        }
        public override void OnNavigatedTo(NavigationContext navigationContext)
        {
            base.OnNavigatedTo(navigationContext);
            UserName = AppSession.UserName;
            LoginId = AppSession.LoginId;
            Phone = AppSession.Phone;
            Photo = "http://localhost:8090/upload/" + AppSession.Photo;
            RoleName = AppSession.RoleId == 1 ? "系统管理员" : (AppSession.RoleId == 1 ? "普通管理员" : "VIP用户");
        }
    }
}
